import { onUnmounted } from 'vue';

import { StompClientService, type StompSubscriber } from 'my-stomp-helper';

export function useStompSubscriber(): StompSubscriber {
  const stompSubscriber = StompClientService.createSubscriber();

  onUnmounted(() => stompSubscriber.clear());

  return stompSubscriber;
}
